编写一个求a+| b |的程序,其中a,b为两个整数

来源:百度知道 编辑:UC知道 时间:2024/06/03 18:37:56
c 编写

#include<stdio.h>
void main()
{
long a,b,sum;
printf("input a,b\n");
scanf("%d,%d",&a,&b);
b=abs(b);
sum=a+b;
printf("a+|b|=%d",sum);
}

#include <math.h>
#include <stdio.h>
main ()
{
int a,b,x,sum;
scanf("%d,%d",&a,&b);
x=abs(b);
sum=a+x;
}

#include<iostream>
void main()
{
double a,b,c;
cout<<"请输入两个数:"<<endl;
cin>>a>>b;
if(b<0)
{ c=a-b;
}
else
{ c=a+b;
}
cout<<"这两个数相加为:"<<c<<endl;
}

#include<stdio.h>
#include<math.h>
void main()
{ long a,b;sum;
printf("input a,b");
scanf("%d%d",&a,&b);
b=fabs(b);
sum=a+b;
printf("a+|b|=%d",sum);
}

......
void main()<